import 'package:yp_object_mapper/mapper.dart';

class Message extends ObjectMapper {
  int? code;
  int? op;
  int? sop;
  int? opid;
  int? wopid;
  String? sp;
  dynamic data;

  Message({
    this.code,
    this.op,
    this.sop,
    this.opid,
    this.wopid,
    this.sp,
    this.data,
  });

  @override
  Future<void> fromMap(map) async {
    code = map['code'] as int?;
    op = map['op'] as int?;
    sop = map['sop'] as int?;
    opid = map['opid'] as int?;
    wopid = map['wopid'] as int?;
    sp = map['sp'] as String?;
    data = map['data'] as String?;
  }

  @override
  Future toMap() async {
    return {
      if (code != null) 'code': code,
      if (op != null) 'op': op,
      if (sop != null) 'sop': sop,
      if (opid != null) 'opid': opid,
      if (wopid != null) 'wopid': wopid,
      if (sp != null) 'sp': sp,
      if (data != null) 'data': data,
    };
  }
}
